/*
* Write hoppscotch-common related custom styles in this file.
* If styles are sharable across all package then write into hoppscotch-ui/assets/scss/styles.scss file.
*/

* {
  backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -webkit-backface-visibility: hidden;

  &::before {
    backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  &::after {
    backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  @apply selection:bg-accentDark;
  @apply selection:text-accentContrast;
  @apply overscroll-none;
}

:root {
  @apply antialiased;
  accent-color: var(--accent-color);
  font-variant-ligatures: common-ligatures;
}

::-webkit-scrollbar-track {
  @apply bg-transparent;
  @apply border-b-0 border-l border-r-0 border-t-0 border-solid border-dividerLight;
}

::-webkit-scrollbar-thumb {
  @apply bg-divider bg-clip-content;
  @apply rounded-full;
  @apply border-4 border-solid border-transparent;
  @apply hover:bg-dividerDark;
  @apply hover:bg-clip-content;
}

::-webkit-scrollbar {
  @apply w-4;
  @apply h-0;
}

.no-scrollbar {
  scrollbar-width: none;
}

input::placeholder,
textarea::placeholder,
.cm-placeholder {
  @apply text-secondary;
  @apply opacity-50 #{!important};
}

input,
textarea {
  @apply text-secondaryDark;
  @apply font-medium;
}

html {
  scroll-behavior: smooth;
}

body {
  @apply bg-primary;
  @apply text-body text-secondary;
  @apply font-medium;
  @apply select-none;
  @apply overflow-x-hidden;
  @apply leading-body #{!important};
  animation: fade 300ms forwards;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

@keyframes fade {
  0% {
    @apply opacity-0;
  }

  100% {
    @apply opacity-100;
  }
}

.fade-enter-active,
.fade-leave-active {
  @apply transition-opacity;
}

.fade-enter-from,
.fade-leave-to {
  @apply opacity-0;
}

.slide-enter-active,
.slide-leave-active {
  @apply transition;
  @apply duration-300;
}

.slide-enter-from,
.slide-leave-to {
  @apply transform;
  @apply translate-x-full;
}

.bounce-enter-active,
.bounce-leave-active {
  @apply transition;
}

.bounce-enter-from,
.bounce-leave-to {
  @apply transform;
  @apply scale-95;
}

.svg-icons {
  @apply flex-shrink-0;
  @apply overflow-hidden;
  height: var(--line-height-body);
  width: var(--line-height-body);
}

a {
  @apply inline-flex;
  @apply text-current;
  @apply no-underline;
  @apply transition;
  @apply leading-body;
  @apply focus:outline-none;

  &.link {
    @apply items-center;
    @apply px-1 py-0.5;
    @apply -mx-1 -my-0.5;
    @apply text-accent;
    @apply rounded;
    @apply hover:text-accentDark;
    @apply focus-visible:ring;
    @apply focus-visible:ring-accent;
    @apply focus-visible:text-accentDark;
  }
}

hr {
  @apply border-b border-dividerLight;
  @apply my-2 #{!important};
}

.heading {
  @apply font-bold;
  @apply text-lg text-secondaryDark;
  @apply tracking-tight;
}

.input,
.select,
.textarea {
  @apply flex;
  @apply w-full;
  @apply px-4 py-2;
  @apply bg-transparent;
  @apply rounded;
  @apply text-secondaryDark;
  @apply border border-divider;
  @apply focus-visible:border-dividerDark;
}

input,
select,
textarea,
button {
  @apply truncate;
  @apply transition;
  @apply text-body;
  @apply leading-body;
  @apply focus:outline-none;
  @apply disabled:cursor-not-allowed;
}

.input[type="file"],
.input[type="radio"],
#installPWA {
  @apply hidden;
}

.floating-input ~ label {
  @apply absolute;
  @apply px-2 py-0.5;
  @apply m-2;
  @apply rounded;
  @apply transition;
  @apply origin-top-left;
}

.floating-input:focus-within ~ label,
.floating-input:not(:placeholder-shown) ~ label {
  @apply bg-primary;
  @apply transform;
  @apply origin-top-left;
  @apply scale-75;
  @apply -translate-y-4 translate-x-1;
}

.floating-input:focus-within ~ label {
  @apply text-secondaryDark;
}

.floating-input ~ .end-actions {
  @apply absolute;
  @apply right-[.05rem];
  @apply inset-y-0;
  @apply flex;
  @apply items-center;
}

.floating-input:has(~ .end-actions) {
  @apply pr-12;
}

pre.ace_editor {
  @apply font-mono;
  @apply resize-none;
  @apply z-0;
}

.select {
  @apply appearance-none;
  @apply cursor-pointer;

  &::-ms-expand {
    @apply hidden;
  }
}

.info-response {
  color: var(--status-info-color);
  &.outlined {
    border: 1px solid var(--status-info-color);
  }
}

.success-response {
  color: var(--status-success-color);
  &.outlined {
    border: 1px solid var(--status-success-color);
  }
}

.redirect-response {
  color: var(--status-redirect-color);
  &.outlined {
    border: 1px solid var(--status-redirect-color);
  }
}

.critical-error-response {
  color: var(--status-critical-error-color);
  &.outlined {
    border: 1px solid var(--status-critical-error-color);
  }
}

.server-error-response {
  color: var(--status-server-error-color);
  &.outlined {
    border: 1px solid var(--status-server-error-color);
  }
}

.missing-data-response {
  color: var(--status-missing-data-color);
  &.outlined {
    border: 1px solid var(--status-missing-data-color);
  }
}

.toasted-container {
  @apply max-w-md;
  @apply z-[10000];

  .toasted {
    &.toasted-primary {
      @apply px-4 py-2;
      @apply bg-tooltip;
      @apply border-secondaryDark;
      @apply text-body text-primary;
      @apply justify-between;
      @apply shadow-lg;
      @apply font-semibold;
      @apply transition;
      @apply leading-body;
      @apply sm:rounded;
      @apply sm:border;

      .action {
        @apply relative;
        @apply flex flex-shrink-0;
        @apply text-body;
        @apply px-4;
        @apply my-1;
        @apply ml-auto;
        @apply normal-case;
        @apply font-semibold;
        @apply leading-body;
        @apply tracking-normal;
        @apply rounded;
        @apply last:ml-4;
        @apply sm:ml-8;
        @apply before:absolute;
        @apply before:bg-current;
        @apply before:opacity-10;
        @apply before:inset-0;
        @apply before:transition;
        @apply before:content-[''];
        @apply hover:no-underline;
        @apply hover:before:opacity-20;
      }
    }

    &.info {
      @apply bg-accent;
      @apply text-accentContrast;
      @apply border-accentDark;
    }

    &.error {
      @apply bg-red-200;
      @apply text-red-800;
      @apply border-red-400;
    }

    &.success {
      @apply bg-green-200;
      @apply text-green-800;
      @apply border-green-400;
    }
  }
}

.splitpanes__pane {
  @apply will-change-auto;
  transform: translateZ(0);
}

.smart-splitter .splitpanes__splitter {
  @apply relative;
  @apply before:absolute;
  @apply before:inset-0;
  @apply before:bg-accentLight;
  @apply before:opacity-0;
  @apply before:z-20;
  @apply before:transition;
  @apply before:content-[''];
  @apply hover:before:opacity-100;
}

.no-splitter .splitpanes__splitter {
  @apply relative;
}

.smart-splitter.splitpanes--vertical > .splitpanes__splitter {
  @apply w-0;
  @apply before:-left-0.5;
  @apply before:-right-0.5;
  @apply before:h-full;
  @apply bg-divider;
}

.smart-splitter.splitpanes--horizontal > .splitpanes__splitter {
  @apply h-0;
  @apply before:-top-0.5;
  @apply before:-bottom-0.5;
  @apply before:w-full;
  @apply bg-divider;
}

.no-splitter.splitpanes--vertical > .splitpanes__splitter {
  @apply w-0;
  @apply pointer-events-none;
  @apply bg-dividerLight;
}

.no-splitter.splitpanes--horizontal > .splitpanes__splitter {
  @apply h-0;
  @apply pointer-events-none;
  @apply bg-dividerLight;
}

.splitpanes--horizontal .splitpanes__pane {
  @apply transition-none;
}

.splitpanes--vertical .splitpanes__pane {
  @apply transition-none;
}

.cm-focused {
  @apply select-auto;
  @apply outline-none #{!important};

  .cm-activeLine {
    @apply bg-primaryLight;
  }

  .cm-activeLineGutter {
    @apply bg-primaryDark;
  }
}

.cm-scroller {
  @apply overscroll-y-auto;
}

.cm-editor {
  .cm-line::selection {
    @apply bg-accentDark #{!important};
    @apply text-accentContrast #{!important};
  }

  .cm-line ::selection {
    @apply bg-accentDark #{!important};
    @apply text-accentContrast #{!important};
  }
}

.shortcut-key {
  @apply inline-flex;
  @apply font-sans;
  @apply text-tiny;
  @apply bg-dividerLight;
  @apply rounded;
  @apply ml-2;
  @apply px-0.5;
  @apply min-w-[1rem];
  @apply min-h-[1rem];
  @apply leading-none;
  @apply items-center;
  @apply justify-center;
  @apply border border-dividerDark;
  @apply shadow-sm;
  @apply <sm:hidden;
}

.capitalize-first {
  @apply first-letter:capitalize;
}

details {
  @apply select-none;
}

details summary::-webkit-details-marker {
  @apply hidden;
}

details summary .indicator {
  @apply transition;
}

details[open] summary .indicator {
  @apply transform;
  @apply rotate-90;
}

@media (max-width: 767px) {
  main {
    margin-bottom: env(safe-area-inset-bottom);
  }
}

.env-highlight,
.predefined-variable-highlight {
  // forcing the text colour to be white inside a highlighted environment variable and predefined variable
  @apply text-accentContrast #{!important};
  span {
    @apply text-accentContrast #{!important};
  }

  // setting the text colour to be visible when it's selected and common item is highlighted
  .cm-selectionMatch {
    @apply text-secondaryDark #{!important};
    span {
      @apply text-secondaryDark #{!important};
    }
  }
}

.env-highlight {
  &.request-variable-highlight {
    @apply bg-amber-500;
    @apply hover:bg-amber-600;
  }

  &.collection-variable-highlight {
    @apply bg-purple-500;
    @apply hover:bg-purple-600;
  }

  &.environment-variable-highlight {
    @apply bg-green-500;
    @apply hover:bg-green-600;
  }

  &.global-variable-highlight {
    @apply bg-blue-500;
    @apply hover:bg-blue-600;
  }

  &.environment-not-found-highlight {
    @apply bg-red-500;
    @apply hover:bg-red-600;
  }
}

.predefined-variable-highlight {
  &.predefined-variable-valid {
    @apply bg-yellow-500;
    @apply hover:bg-yellow-600;
  }

  &.predefined-variable-invalid {
    @apply hover:bg-red-300;
    @apply bg-red-300;
  }
}

#nprogress .bar {
  @apply bg-accent #{!important};
}

.color-picker[type="color"] {
  @apply appearance-none;
}

.color-picker[type="color"]::-webkit-color-swatch-wrapper {
  @apply rounded;
  @apply p-0;
}

.color-picker[type="color"]::-webkit-color-swatch {
  @apply rounded;
  @apply border-0;
}

.gql-operation-not-highlight {
  @apply opacity-50;
}

.gql-operation-highlight {
  @apply opacity-100;
}
